const router = require('koa-router')()
const api = require('../service/index')
router.get('/login', async (ctx, next) => {
  let res = await api.login(ctx.query)
  if (res.suc) {
    ctx.body = JSON.stringify({ errcode: 0, errmsg: 'ok', data: res.data || {} })
  } else {
    ctx.body = JSON.stringify({ errcode: -1, errmsg: 'err' })
  }
})

router.get('/register', async (ctx, next) => {
  ctx.set('Content-Type', 'application/json')
  ctx.body = JSON.stringify({ errcode: 0, errmsg: 'ok', data: [1, 2, 3] })
})

router.get('/json', async (ctx, next) => {})

module.exports = router
